def is_onetime(str1, str2):
    if str1 is None or str2 is None:
        raise Exception('非法输入')

    if len(str1) == len(str2):
        diff = 0
        for i, j in zip(range(len(str1)), range(len(str2))):
            if str1[i] != str2[j]:
                diff += 1
        return diff < 2

    if abs(len(str1) - len(str2)) > 1:
        return False

    if len(str1) - len(str2) > 0:
        longer, shorter = str1, str2
    else:
        longer, shorter = str2, str1
    i, j = 0, 0
    while i < len(shorter) and j < len(longer):
        if shorter[i] != longer[j]:
            j += 1
        i += 1
        j += 1
    return i == len(shorter) and (j == len(longer) or j == len(longer) - 1)


str1 = 'abc'
str2 = 'abc'
print(is_onetime(str1, str2))
